package work.cxz.MimeDemo;



import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * @author Gong.Yang
 */
public class Demo {
    public static void main(String[] args) throws IOException {
        // 图片文件的路径
        String basePath = "E:\\work-records\\c陈锡忠\\s-图片memi类型转换\\";
        String imagePath = basePath + "原始材料\\8ac21a3a-7b91-4787-9ee3-4b5b271ea005.jpeg"; // 替换为你的图片文件路径
        String outPath = basePath + "测试输出\\";
        String outFile = outPath+System.currentTimeMillis()+".jpg";

        convertHeifToJpgOrPng(imagePath,outFile,"jpg");


    }

    public static void convertHeifToJpgOrPng(String inputFilePath, String outputFilePath, String format) throws IOException {
        BufferedImage image = ImageIO.read(new File(inputFilePath));
        File outputFile = new File(outputFilePath);

        ImageIO.write(image, format, outputFile);
        System.out.println("HEIF image converted to " + format.toUpperCase() + " successfully.");
    }
}
